﻿using System;

namespace Borg
{
    [Serializable]
    public class SlotDefinition : Qualifiable
    {
        private bool _isThreadsafe;
        private Contract _contract;

        private MetaElementCollection<ParamDefinition> _paramDefinitions;
        private MetaElementCollection<TagDefinition> _tagDefinitions;

        private string _typeName;

        public bool IsThreadsafe
        {
            get { return _isThreadsafe; }
            private set { _isThreadsafe = value; }
        }

        public Contract Contract
        {
            get { return _contract; }
            internal set { _contract = value; }
        }

        public MetaElementCollection<ParamDefinition> ParamDefinitions
        {
            get { return _paramDefinitions; }
            internal set { _paramDefinitions = value; }
        }

        public MetaElementCollection<TagDefinition> TagDefinitions
        {
            get { return _tagDefinitions; }
            internal set { _tagDefinitions = value; }
        }

        public string TypeName
        {
            get { return _typeName; }
            internal set { _typeName = value; }
        }

        public override bool IsQualified
        {
            get { return Qualifier.IsQualified(this); }
        }

        internal SlotDefinition(int id, string name, bool isThreadsafe)
            : base(id, name)
        {
            IsThreadsafe = isThreadsafe;
        }

        public override bool Qualify()
        {
            return Qualifier.Qualify(this);
        }

        internal override AssemblyElement GetAssemblyElement()
        {
            return Contract;
        }
    }
}
